package com.ljfiction.book.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljfiction.book.Baner.ReadDuanBean;
import com.ljfiction.book.R;
import com.ljfiction.book.tools.ScreenUtils;
import com.ljfiction.book.tools.TimeTool;

import java.util.List;

/**
 * Created by Android on 2017/10/25.
 */

public class ReadDuanpingAdapter extends BaseQuickAdapter<ReadDuanBean.DataBean.ListBean, BaseViewHolder> {
    public ReadDuanpingAdapter(@LayoutRes int layoutResId, @Nullable List<ReadDuanBean.DataBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ReadDuanBean.DataBean.ListBean item) {
        helper.addOnClickListener(R.id.zanimage);
        helper.addOnClickListener(R.id.myshuping_read);
        Glide.with(mContext).load(item.getUserHeadPortraitURL()).override(ScreenUtils.getNum(mContext,52),ScreenUtils.getNum(mContext,52)).into((ImageView) helper.getView(R.id.myshuping_read));
        if (item.getIsthumbs() == 1) {
            ((ImageView) helper.getView(R.id.zanimage)).setImageResource(R.mipmap.good);
        } else {
            ((ImageView) helper.getView(R.id.zanimage)).setImageResource(R.mipmap.goodno);
        }

        helper.setText(R.id.content_myshuping_read,item.getCommentContext())
                .setText(R.id.myshuping_myname_read,item.getPseudonym())
                .setText(R.id.diannum_read,String.valueOf(item.getThumbsCount()))
                .setText(R.id.mushupingtime_read, TimeTool.getTimeAndChange(String.valueOf(item.getCommentDateTime())))
                .setText(R.id.shupingdenglimy_read,"LV"+item.getUserGrade());
        if (item.getUserSex()==0){
            ((ImageView) helper.getView(R.id.myshupingsex_read)).setImageResource(R.mipmap.sex_n);
        }else {
            ((ImageView) helper.getView(R.id.myshupingsex_read)).setImageResource(R.mipmap.sex_v);
        }
        if (item.getVipGrade()>0){
            helper.getView(R.id.isvipimage_shuping_read).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.isvipimage_shuping_read).setVisibility(View.GONE);
        }
    }

}
